package com.yvon.service.demo.spring.beans.factory.support;

import com.yvon.service.demo.spring.core.io.DefaultResourceLoader;
import com.yvon.service.demo.spring.core.io.ResourceLoader;

/**
 * bean定义信息读取器抽象类
 *
 * @author : Yvon
 * @since : 2022-12-06
 */
public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader {

    /**
     * 注册表
     */
    private final BeanDefinitionRegistry registry;

    /**
     * 资源加载器
     */
    private ResourceLoader resourceLoader;

    protected AbstractBeanDefinitionReader(BeanDefinitionRegistry registry) {
        this(registry, new DefaultResourceLoader());
    }

    public AbstractBeanDefinitionReader(BeanDefinitionRegistry registry, ResourceLoader resourceLoader) {
        this.registry = registry;
        this.resourceLoader = resourceLoader;
    }

    /**
     * 获得注册表
     *
     * @return {@code BeanDefinitionRegistry }
     */
    @Override
    public BeanDefinitionRegistry getRegistry() {
        return registry;
    }

    /**
     * 获得资源加载器
     *
     * @return {@code ResourceLoader }
     */
    @Override
    public ResourceLoader getResourceLoader() {
        return resourceLoader;
    }
}
